
<#include
        "../common/com.html"  /> <@layout>
<head>
    <!-- page specific plugin styles -->
    <!-- ace styles -->
    <script src="${ctx}/static/inc/platform/js/ajax.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/cbb/artDialog/skins/blue.css">
    <script src="${ctx}/static/cbb/artDialog/jquery.artDialog.js"></script>
            <script src='${ctx}/static/js/jquery.tools.js' type='text/javascript'></script>
    
</head>
<script type="text/javascript">
    function exports(){
        var start=$("#start").val();
        var end=$("#end").val();

        var url=  "${ctx}/tj/hyktoexcel?search_GTE_bkrq="+start+"&search_LTE_bkrq="+end;
        window.open (url,'报表导出','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
    }


</script>
<body>

<div class="page-content" style="overflow: hidden">

    <div class="row-fluid">
        <div class="span12">
            <form class="form-inline" id="queryTable">
                日期起：<input type="text"  name="search_GTE_bkrq" id="start"   class="query"  style="min-height: 24px;width: 100px"   onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'end\')}'})"      />
                日期止：<input type="text"  name="search_LTE_bkrq" id="end"   class="query"  style="min-height: 24px;width: 100px" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'start\')}'})" />
               卡号：<input type="text"  name="search_LIKE_card" id="card"   class="query"  style="min-height: 24px;width: 100px"  />
               姓名：<input type="text"  name="search_LIKE_yhm" id="yhm"   class="query"  style="min-height: 24px;width: 100px"  />
                <button id="search_btn" onclick="return false;" class="btn btn-info btn-small"  onclick="queryModel()">
                    查询
                </button>
            </form>
            <!-- PAGE CONTENT BEGINS -->
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
            <!-- PAGE CONTENT ENDS -->
        </div><!-- /.span -->
    </div><!-- /.row-fluid -->
</div><!-- /.page-content -->
<!-- page specific plugin scripts -->


<#include  "../common/end.html"  />
<script>
    function add(){
        var url = '${ctx}/hygl/newModes' ;
        window.location.href=url;
        // initArtDialog({url:url, title:'新增', width:600, height:400,lock:true,background: '#EAEAEA'});
    }
    /**
     * 编辑选中的模型信息
     */
    function edits(obj){
        var rowData = $("#grid-table").getRowData(obj);
        var  url = '${ctx}/hygl/newModes?id=' + rowData.id;
        window.location.href=url;

//        initArtDialog({url:url, title:'修改', width:730, height:330,lock:true,background: '#EAEAEA'});
    }
</script>
<script type="text/javascript">
    $("#search_btn").click(function(){
        $("#grid-table").jqGrid('setGridParam',{
            datatype:'json',
            postData:$.getQueryParam('queryTable'), //发送数据 'search_LIKE_lrrq':start
            page:1
        }).trigger("reloadGrid"); //重新载入
    });


    jQuery(function($) {

        //  jqgrid
        var grid_selector = "#grid-table";
        var pager_selector = "#grid-pager";
        var start=$("#start").val();


        jQuery(grid_selector).jqGrid({
            datatype: "json", //将这里改为使用JSON数据
            mtype:"POST",
            postData:{}, //发送数据
            url:'${ctx}/tj/queryhytj',
            height: '55%',
            footerrow:false,  //合计数据
            gridComplete: completeMethod,
            colNames:[
                '卡号',  '姓名',  '办卡日期',  '固定电话',    '原始金额',  '余额', '积分', '已用积分',  '车款',  '车牌号',  '保险日期', ''],
            colModel:[
                {name:'card', width:100,sortable:false},
                {name:'yhm', width:100,sortable:false},
                {name:'bkrq', width:100,sortable:false},
                {name:'gddh', width:100,sortable:false},
                {name:'ysje', width:100,sortable:false},
                {name:'yes', width:100,sortable:false,formatter: ye},
                {name:'jfs', width:100,sortable:false,formatter: jfs},
			    {name:'xfjfs', width:100,sortable:false},

                {name:'ck', width:100,sortable:false},
                {name:'cph', width:100,sortable:false},
                {name:'bxrq', width:100,sortable:false},
                {name:'id',index:'',width:50,sortable:false,hidden:true}
            ],
            rownumbers:true,//添加左侧行号
            sortname: 'id',
            sortable: false,
            viewrecords: true, //是否显示行数
            rowNum:20,
            rowList:[10,20,30],
            loadtext: '正在加载数据...',
            loadui : 'block',
            pager : pager_selector,
            altRows: true,
            shrinkToFit: true,
            //toppager: true,
//
//        multiselect: true,
//        //multikey: "ctrlKey",
//        multiboxonly: true,

            loadComplete : function() {
                var table = this;
                setTimeout(function(){
                            updatePagerIcons(table);
                        },
                        0);
            } ,
    //        ondblClickRow: openview,
//
            caption:  " <input type='button' onclick='exports();' class='btn btn-mini btn-danger' value='导出EXCEL'>" ,
            autowidth: true
        });
        function ye(cellvalue,options,rowObject){
        	var czje=rowObject.czje;
        	var ysjes=rowObject.ysjes;
        	var vipcard=rowObject.vipcard;
            return ysjes+czje-vipcard;
        }
        function jfs(cellvalue,options,rowObject){
        	var vipcard=rowObject.vipcard;
        	var moneys=rowObject.moneys;
            return vipcard+moneys;
        }
    });




    //replace icons with FontAwesome icons like above
    function updatePagerIcons(table) {
        var replacement =
        {
            'ui-icon-seek-first' : 'icon-double-angle-left bigger-150',
            'ui-icon-seek-prev' : 'icon-angle-left bigger-150',
            'ui-icon-seek-next' : 'icon-angle-right bigger-150',
            'ui-icon-seek-end' : 'icon-double-angle-right bigger-150'
        };
        $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){
            var icon = $(this);
            var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

            if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
        })
    }

    function enableTooltips(table) {
        $('.navtable .ui-pg-button').tooltip({container:'body'});
        $(table).find('.ui-pg-div').tooltip({container:'body'});
    }

    //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

    //    $( "#adds" ).on('click', function(e) {
    //        e.preventDefault();
    //        addr();
    //    });
    function completeMethod()
    {

        var start=$("#start").val();
        var end=$("#end").val();


        var url= '${ctx}/tj/queryhytjhj?search_GTE_bkrq='+start+'&search_LTE_bkrq='+end;
        $.ajax({ url:url,async:false,  dataType: "json",
            success: function(data){
                var objs= JSONstringify(data);
                var arr = eval('(' + objs + ')');
                if(arr.length>0){
                    if(arr[0].vipcard !=null){
                        $("#grid-table").footerData('set', { card: '合计:', yhm:arr[0].sums  , yes:arr[0].vipcard+"元"  });
                    }  else{
                        $("#grid-table").footerData('set', { card: '合计:', yhm:arr[0].sums  , yes:"0元"  });
                    }
                }
            }})

    }


    window.onresize = function  _doResize() {
        var ss = pageSize();
        $("#grid-table").jqGrid('setGridWidth', ss.WinW-10).jqGrid('setGridHeight', ss.WinH-200);
    }

    function pageSize() {
        var winW, winH;
        if(window.innerHeight) {// all except IE
            winW = window.innerWidth;
            winH = window.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 Strict Mode
            winW = document.documentElement.clientWidth;
            winH = document.documentElement.clientHeight;
        } else if (document.body) { // other
            winW = document.body.clientWidth;
            winH = document.body.clientHeight;
        }  // for small pages with total size less then the viewport
        return {WinW:winW, WinH:winH};
    }

    //select2查询列表每次只查数据的前20条


    //转json
    function JSONstringify(Json){
        if($.browser.msie){
            if($.browser.version=="7.0"||$.browser.version=="6.0"){
                var  result=jQuery.parseJSON(Json);
            }else{
                var result=JSON.stringify(Json);
            }
        }else{
            var result=JSON.stringify(Json);
        }
        return result;
    }

</script>

</body>
</@layout>
